<?php
/*****************************************************************************
**	Файл:	Вход на игровой сервер											**
**	Автор:	Dark Dayver														**
**	Версия:	1.0b															**
**	Дата:	25/12-2009														**
*****************************************************************************/
if (IN_P_ENIGMA)
{
	die('HACK!');
}

if (SERVER_NO)
{
	if (isset($_SESSION['id']) && $_SESSION['id'] != 0) $work->clean_user();
	if ($work->check_post('user_login', true, true, REG_LOGIN)) $_SESSION['user_login'] = $_POST['user_login'];
	if ($work->check_post('user_login', true, true, REG_LOGIN) && $work->check_post('user_password', true, true, REG_NAME))
	{
		$user->login_user($_POST['user_login'], $_POST['user_password']);
		if ($user->id)
		{
			$user->check_allow_login();
			if ($user->id)
			{
				$_SESSION['id'] = $user->id;
				$db->update(array('date_last_login' => date('Y-m-d H:i:s')), DB_USER, TBL_USERS);
				$db->where('`id` = ' . $user->id);
				$db->query();
				$db->clean();
				$user->last_active();
				header('Location: ' . $work->config['site_url'] . $result['where_last_active']);
				die('HACK!');
			}
		}
		else
		{
			$_SESSION['error'] = true;
			$_SESSION['error_txt'] = $language->error['no_this_user'];
		}
	}
	else
	{
		$_SESSION['error'] = true;
		$_SESSION['error_txt'] = $language->error['field_login_user'];
	}
}
else
{
	$_SESSION['error'] = true;
	$_SESSION['error_txt'] = $language->error['no_out_server'];
}
$user->last_active();
header('Location: ' . $work->config['site_url']);
die('HACK!');
?>
